package com.system.exam.admin.exception;

import com.system.exam.admin.core.http.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    public Result handler(Exception e) {
        log.error("运行时异常:-----" + e.getMessage());
        return Result.error(500, e.getMessage());
    }

    @ExceptionHandler(value = BusinessException.class)
    public Result BusinessHandler(BusinessException e) {
        log.error("参数错误:-----" + e.getMessage());
        return Result.error(500, e.getMessage());
    }
}
